FROM ubuntu:20.04
MAINTAINER Dmitry Kiselev <dmitry@endpoint.com>

RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list

RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt install -y tzdata

RUN \
  apt-get install -y \
    software-properties-common \
    build-essential \
    curl \
    wget \
    git \
    unzip \
    tar \
    ant \
    vim \
    nano \
    parallel \
    osmctools && \
  rm -rf /var/lib/apt/lists/*

# Java for OSM2World
#RUN \
 # echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
  #add-apt-repository -y ppa:webupd8team/java && \
  #apt-get update && \
  #apt-get install -y oracle-java8-installer && \
  #rm -rf /var/lib/apt/lists/* && \
  #rm -rf /var/cache/oracle-jdk8-installer

# Define commonly used JAVA_HOME variable
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64

# Install Node js
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - ;\
    apt-get install -y nodejs

RUN apt-get install -y openjdk-8-jdk

WORKDIR /opt

#RUN npm install -g 3d-tiles-tools obj2gltf

COPY OSM2World-tiled_out.zip .
# Install OSM2World
RUN mkdir /opt/OSM2World && mkdir /opt/OSM2World-release && \
    unzip OSM2World-tiled_out.zip && \
    mv OSM2World-tiled_out/* OSM2World/ && \
    cd /opt/OSM2World && \
    ant release && \
    unzip /opt/OSM2World/build/OSM2World-noversion-bin.zip -d /opt/OSM2World-release && \
    cd /opt && \
    rm -rf /opt/OSM2World/ && \
    rm -rf OSM2World-tiled_out && \
    mv /opt/OSM2World-release /opt/OSM2World

RUN mkdir /opt/gazetteer
   # wget https://github.com/kiselev-dv/gazetteer/releases/download/Gazetteer-1.9rc4/gazetteer.jar -O /opt/gazetteer/gazetteer.jar
COPY gazetteer.jar /opt/gazetteer/

RUN npm config set registry https://registry.npmmirror.com
RUN npm config set loglevel=http
RUN npm install cnpm -g --registry=https://registry.npmmirror.com

RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1

#RUN node-gyp configure
RUN cnpm install -g 3d-tiles-tools obj2gltf

RUN apt-get install -y python2

COPY scripts /opt/scripts

# !!! important
WORKDIR /opt/OSM2World

CMD ["/bin/sh"]

 
